/* $RCSFile: AddonNiceUserDB.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/ADNCRM.Core/DAL/AddonNiceUserDB.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:28  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Diagnostics;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Data.SqlClient;
using System.Globalization;

using AddonNice.Configuration;
using AddonNice.Diagnostics;

namespace AddonNice.Settings
{
    /// <summary>
    /// DB access layer for AddonNiceUser class
    /// </summary>
    public class AddonNiceUserDB : DBDataStore
    {
		/// <summary>
		/// Extacts civilities list from DB
		/// </summary>
		public SqlDataReader GetAllCivilities()
        {
            SqlCommand myCommand = new SqlCommand("dbo.adn_GetAllUserCivilites", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;


            SqlParameter parameterLeadId = new SqlParameter("@CiviliteLangID", SqlDbType.Int, 4);
            parameterLeadId.Value = LCID;
            myCommand.Parameters.Add(parameterLeadId);

            //  Execute the command
            SqlDataReader result = null;
            try
            {
                myConnection.Open();
                result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
            }
            catch (Exception exp)
            {
                if ( DBTraceSwitch.Sw.TraceError )
                    Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"AddonNiceUserCivilite GetAllCivilite ex : {0}", exp),DBTraceSwitch.Sw.Info);
                if (result != null)
                    result.Close();
                if (myConnection.State == System.Data.ConnectionState.Open)
                    myConnection.Close();
                throw;
            }
            return result;
        }
	}
}
